﻿namespace NetDon.OA.Portal.Admin
{
    using System;
    using Data.EntityClasses;
    using Utilities;

    [Navigation("我的个人信息")]
    public partial class MyProfile : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var context = ServiceContainer.GetService<ApplicationContext>();
                var userEntity = new UserEntity(context.UserId);
                if (!userEntity.IsNew)
                {
                    fpUserInfo.DataSource = userEntity;
                    fpUserInfo.DataBind();
                }
            }
        }

        protected void btnRegister_Click(object sender, EventArgs e)
        {
            var context = ServiceContainer.GetService<ApplicationContext>();
            var userEntity = new UserEntity(context.UserId);
            if (!userEntity.IsNew)
            {
                fpUserInfo.ExtractValues(userEntity, false);
                if (userEntity.Save())
                {
                    base.Success("保存成功!");
                    //base.Success(GetResourceString("RegisterOK"));
                }
            }
        }
    }
}